//
//  JavascriptProject.h
//  iCodeMac
//
//  Created by Andrew Barry on 16/03/09.
//  Copyright 2009 Barry Computer Services. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "CodeTarget.h"

@class DebugConnection;
@class WrappedJsval;
@class jvm;

@interface JavascriptProject : NSDocument {
	NSDictionary *saved;
	NSMutableArray *projectItems;
	NSString *projType;
	NSMutableDictionary *settings;
	NSString *debugKey;
	DebugConnection *debugConnection;
	bool isStopped;
	NSMutableDictionary *userSettings;
	
	NSString *currentStopFilename;
	int currentStopLine;
	bool breakpointsChanged;
	
	WrappedJsval *debugPanel;
	bool buildingForRelease;
}
+(JavascriptProject *) projectForDocument: (NSDocument *) doc;
-(id<CodeTarget>) target;

-(jvm*) jvmInstance;
-(bool) isOSXProject;
-(bool) isOSXApplication;
-(bool) isWin32Project;
-(bool) isWebProject;
-(bool) isConsoleProject;
-(bool) isPadProject;

-(void)	displayCompilationError: (NSString *) errorMessage forFile: (NSString *) path forControl: (NSString *) ctlName forEvent: (NSString *) eventName atLine: (int) line;
-(void) showError: (NSString *) message withHeader: (NSString *) header;

-(bool)buildApplicationForRelease: (bool) forRelease chainTo: (SEL) chain;
-(NSString *) buildPath;
-(int)projectItemCount;
//-(NSString *)pathForItem: (NSString *) item;
-(NSString *)pathForItemIndex: (int) idx;
-(NSString *)pathTo: (NSString *)name;
-(NSString *)debugKey;
-(void) setDebugKey: (NSString *) key;
-(NSMutableArray *) items;
-(NSString *) projectFolder;
-(NSString *) buildName;
-(void)clearStop;

-(void) loadUserSettings;

-(void)stepInto: (id) sender;
-(void)stepOut: (id) sender;
-(void)stepOver: (id) sender;
-(void)debugRun: (id) sender;
-(void)debugStop: (id) sender;

-(NSString *)currentStopFilename;
-(int)currentStopLine;

-(void) saveFrame: (NSRect) f forWindow: (NSString *) name;
-(bool) savedFrame: (NSRect *) pf forWindow: (NSString *) name;

-(NSArray *) breakpointsForWindow:(NSString *) name;
-(void) saveBreakpoints: (NSArray *) arr forWindow: (NSString *) name;

-(void) startedDebugging: (DebugConnection *) sender;
-(void) debugEnded: (DebugConnection *) sender;
-(void) debugFatalError: (id) packet;
-(void) debugStr: (NSString *) msg;
-(void) debugger: (NSDictionary *) packet;
-(NSDocument *) displaySource: (NSString*) filename atLine: (int) lineno;

-(NSObject *) getProperty: (NSString *)propname;
-(void) setProjectProperties: (NSDictionary *) settings;

-(bool) isDebugging;
-(bool) isStopped;
-(void)updateEditing;

-(BOOL) databaseEnabled;
-(void) linkToProgram: (NSString *) path;

-(void)showBuildSheet;
-(void)clearBuildSheet;

-(NSString *) appVersion;
-(NSString *) appIdentifier;

@end
